package com.my.mvc.fullbean;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import com.my.mvc.actionsupport.MyActionSupport;

public class FullBean {
	public static MyActionSupport fullBean(HttpServletRequest request) {
		MyActionSupport myActionSupport = null;
		String beanName = request.getParameter("sign");
		try {
			Class<?> clazz = Class.forName(beanName);
			myActionSupport = (MyActionSupport) clazz.newInstance();
			Field[] fields = clazz.getDeclaredFields();
			for (Field field : fields) {
				String fieldName = field.getName();
				String FieldValue = request.getParameter(fieldName);
				field.setAccessible(true);
				field.set(myActionSupport, FieldValue);
				field.setAccessible(false);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return myActionSupport;
	}
}
